package com.open.capacity.user.service.impl;

import com.open.capacity.user.dao.SysUsersettingDefaultDao;
import com.open.capacity.user.model.SysUsersettingDefault;
import com.open.capacity.user.service.SysUsersettingDefaultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;


@Service
public class SysUsersettingDefaultServiceImpl implements SysUsersettingDefaultService {

    @Autowired
    private SysUsersettingDefaultDao sysUsersettingDefaultDao;

    /**
     * 添加
     *
     * @param sysUsersettingDefault
     */
    public int saveOrUpdate(SysUsersettingDefault sysUsersettingDefault) {
        SysUsersettingDefault model = sysUsersettingDefaultDao.findById(sysUsersettingDefault.getUserid());
        if (model == null) {
            sysUsersettingDefault.setUpdateTime(new Date());
            sysUsersettingDefaultDao.save(sysUsersettingDefault);
        } else {
            sysUsersettingDefault.setUpdateTime(new Date());
            sysUsersettingDefaultDao.update(sysUsersettingDefault);
        }
        return 1;
    }


    /**
     * 删除
     *
     * @param id
     */
    public int delete(String id) {
        return sysUsersettingDefaultDao.delete(id);
    }

    /**
     * 查询记录
     *
     * @param id
     * @return
     */
    public SysUsersettingDefault findById(String id) {
        return sysUsersettingDefaultDao.findById(id);
    }

}
